package android.tusnotas.changes;

import android.content.Context;
import android.content.res.Resources;
import android.tusnotas.activities.R;
import android.tusnotas.beans.Course;
import android.tusnotas.beans.Grade;
import android.tusnotas.util.NotificationLevels;
import android.tusnotas.util.PropertyLoader;

public class GradeChange implements Change{
	
	private Resources res;
	private Grade before;
	private Grade after;
	private Course course;
	
	public GradeChange() {
		super();
	}
	
	public GradeChange(Context context, Grade before, Grade after, Course course) {
		super();
		this.res = context.getResources();
		this.before = before;
		this.after = after;
		this.course = course;
	}
	
	public String getBarTitle(){
		return res.getString(R.string.notification_new_grade_title);
	}
	
	public String getTitle(){
		if(this.before.getGrade().trim().equalsIgnoreCase("-"))
			return res.getString(R.string.notification_new_grade);
		else
			return res.getString(R.string.notification_change_grade);
	}
	
	public Integer getInstanceId(){
		return course.getInstanceId();
	} 
	
	public Integer getCourseId(){
		return course.getId();
	}
	
	public String getContent(){
		if(res.getConfiguration().locale.getLanguage().equalsIgnoreCase("en")){
			return getEnglishContent();
		}else{
			return getSpanishContent();
		}
	};
	
	private String getEnglishContent() {
		switch (PropertyLoader.NOTIF_LEVEL) {
		case NotificationLevels.NOTIF_LEVEL_MEDIUM:
			return "The grade of the "+ this.after.getActivity()+" of "+this.course.getName();
		case NotificationLevels.NOTIF_LEVEL_HARD:
			return ""+this.after.getGrade()+" in the "+ this.after.getActivity()+" of "+this.course.getName();
		default:
			return "You got a new grade";
		}
	}

	private String getSpanishContent() {
		String articulo = "el";
		if(this.after.getActivity().equalsIgnoreCase("ACTIV.") ||this.after.getActivity().equalsIgnoreCase("ASIST")){
			articulo = "la";
		}
		switch (PropertyLoader.NOTIF_LEVEL) {
		case NotificationLevels.NOTIF_LEVEL_MEDIUM:
			if(articulo.equals("el"))
				return "La nota del "+ this.after.getActivity()+" de "+this.course.getName();
			else
				return "La nota de la "+ this.after.getActivity()+" de "+this.course.getName();
		case NotificationLevels.NOTIF_LEVEL_HARD:
			return ""+this.after.getGrade()+" en "+articulo+" "+ this.after.getActivity()+" de "+this.course.getName();
		default:
			return "Te pusieron una nota";
		}
	}

	public Grade getBefore() {
		return before;
	}
	
	public void setBefore(Grade before) {
		this.before = before;
	}
	
	public Grade getAfter() {
		return after;
	}
	
	public void setAfter(Grade after) {
		this.after = after;
	}

}
